package cn.getech.data.metadata.controller.api;

import cn.getech.data.intelligence.common.utils.R;
import cn.getech.data.metadata.api.RegisterApi;
import cn.getech.data.metadata.service.CollectionRegisterService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName BuildDataQualityReportController
 * @Description   元数据接口
 * @Author Getech
 * @Date 2021/2/5 10:40
 */

@RestController
@Slf4j
public class RegisterController implements RegisterApi {

    @Autowired
    private CollectionRegisterService collectionRegisterService;

    @Override
    public R register() {
        try {
          //  log.info("开始获取元数据:{}",System.currentTimeMillis());
            collectionRegisterService.register();
          //  log.info("结束获取元数据:{}",System.currentTimeMillis());
        } catch (Exception e) {
            log.error("获取元数据异常", e);
            R.okWithData(e.getMessage());
        }
        return R.ok();
    }

    @Override
    public R init() {
        try {
            log.info("开始初始化元数据:{}",System.currentTimeMillis());
            collectionRegisterService.init();
            log.info("结束初始化元数据:{}",System.currentTimeMillis());
        } catch (Exception e) {
            log.error("初始化元数据异常", e);
            R.okWithData(e.getMessage());
        }
        return R.ok();
    }


}
